package inherit;

public class InheritDemo {
    public static void main(String[] args) {
        Student s = new Student();
        s.show();
        s.fuFUn();
        OverSeaStudent os = new OverSeaStudent();
        os.eat();
    }
}

class Student extends Person {
    String hobby = "学习";
    public void show(){
        String hobby = "睡觉";
        //就近原则
        System.out.println(hobby);
        //this 表示当前实例的对象
        System.out.println(this.hobby);
        //super 表示父类的对象
        System.out.println(super.hobby);
    }
    public void fuFUn(){
        this.eat();
        super.sleep();
    }
}
class OverSeaStudent extends Student {
    //当父类中的方法不满足需求时，可以重写父类中的方法，重写需要加上 @Override 注解
    @Override
    public void eat(){
        System.out.println("我在吃海鲜");
    }
}
